package servlet;

import dao.ProductTypeDao;
import bean.Result;
import com.google.gson.Gson;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RemoveMinitypeServlet", value = "/RemoveMinitypeServlet.s")
public class RemoveMinitypeServlet extends HttpServlet {
    private ProductTypeDao dao = new ProductTypeDao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final String typedetailid = request.getParameter("typedetailid");
        Result result = null;
        try{
            final int status = dao.deleteMiniType(typedetailid);
            result = new Result(1,"删除成功",null);
        }catch (Exception e){
            result = new Result(0,"删除失败",null);
        }
        final String json = new Gson().toJson(result);
        response.getWriter().append(json);
    }
}
